﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace JuCloudy.Platform.UserControls
{
    public partial class IconButton : UserControl
    {
        public IconButton()
        {
            InitializeComponent();
            ImageProperty = DependencyProperty.Register("Image", typeof(ImageSource), typeof(IconButton),
                new PropertyMetadata(new BitmapImage(new Uri("/JuCloudy.Platform.UserControls;component/Resources/DefaultIcon.png")),
                    new PropertyChangedCallback((obj, e) =>
                    {
                        this._img.Source = (ImageSource)e.NewValue;
                    })));
        }

        public event RoutedEventHandler Click;

        private void _btn_Click(object sender, RoutedEventArgs e)
        {
            if (this.Click != null)
                this.Click.Invoke(sender, e);
        }

        private DependencyProperty ImageProperty;
        public ImageSource Image
        {
            get { return (ImageSource)GetValue(ImageProperty); }
            set { SetValue(ImageProperty, value); }
        }
    }
}
